package com.qst.mapper;

import com.qst.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.sql.Timestamp;
import java.util.List;

public interface UserMapper {

    List<User> findAll();

    List<User> findAllWithLastLogin();

    List<User> findAll2();

    int delUserById(int id);

    @Select("select * from users where id = #{id}")
    User findUserById(int id);

    User findByLogin(@Param("loginName") String login);

    int insertUser(User user);

    int updateUser(User user);
    @Update("UPDATE users a SET a.passwd = #{passwd} WHERE a.id = #{id}")
    int resetPwdbyId(User user);

    @Select("select * from users where id = #{id}")
    User findById(int creatorId);

    @Update("UPDATE users SET last_login = #{lastLogin} WHERE id = #{id}")
    void updateLastLogin(@Param("id") int id, @Param("lastLogin") Timestamp lastLogin);

    void updatePassword(@Param("id") int id, @Param("passwd") String passwd);
}
